<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
	<title>中小企业</title>
</head>
<body>
		<div class="weui-panel__hd" id="returnBtn" position="top">&lt 返回列表</div>
		<div position="center">
		    <div class="page__bd">
		        <div class="weui-form-preview">
		            <div class="weui-form-preview__hd">
		                <div class="weui-form-preview__item">
		                    <label class="weui-form-preview__label">服务名称</label>
		                    <em class="weui-form-preview__value" id="service_name"></em>
		                </div>
		            </div>
		            <div class="weui-form-preview__bd">
		                <div class="weui-form-preview__item">
		                    <label class="weui-form-preview__label">分类</label>
		                    <span class="weui-form-preview__label" id="service_type"></span>
		                </div>
		                <div class="weui-form-preview__item">
		                    <label class="weui-form-preview__label">地区</label>
		                    <span class="weui-form-preview__label" id="service_area"></span>
		                </div>
		                <div class="weui-form-preview__item">
		                    <label class="weui-form-preview__label">申请次数</label>
		                    <span class="weui-form-preview__label" id="req_count"></span>
		                </div>
		                <div class="weui-form-preview__item">
		                    <label class="weui-form-preview__label">服务机构</label>
		                    <span class="weui-form-preview__label" id="service_org"></span>
		                </div>
		                <div class="weui-form-preview__item">
		                    <label class="weui-form-preview__label">服务方式</label>
		                    <span class="weui-form-preview__label" id="service_way"></span>
		                </div>
		                <div class="weui-form-preview__item">
		                    <label class="weui-form-preview__label">联系人</label>
		                    <span class="weui-form-preview__label" id="person"></span>
		                </div>
		                <div class="weui-form-preview__item">
		                    <label class="weui-form-preview__label">发布时间</label>
		                    <span class="weui-form-preview__label" id="pubtime"></span>
		                </div>
		                <div class="weui-form-preview__item">
		                    <label class="weui-form-preview__label">所在地区</label>
		                    <span class="weui-form-preview__label" id="area"></span>
		                </div>
		                <div class="weui-form-preview__item">
		                    <label class="weui-form-preview__label">服务说明</label>
		                    <span class="weui-form-preview__label" id="service_desc"></span>
		                </div>
		                <div class="weui-form-preview__item">
		                    <label class="weui-form-preview__label">服务资质</label>
		                    <span class="weui-form-preview__label" id="service_qua"></span>
		                </div>
		                <div class="weui-form-preview__item">
		                    <label class="weui-form-preview__label">收费标准</label>
		                    <span class="weui-form-preview__label" id="service_charge"></span>
		                </div>
		                <div class="weui-form-preview__item">
		                    <label class="weui-form-preview__label">申请服务</label>
		                </div>
		                <div class="weui-cells weui-cells_form" style="margin-left: -15px;margin-right:  -15px;">
						    <div class="weui-cell">
						        <div class="weui-cell__bd">
						            <textarea class="weui-textarea" placeholder="申请服务说明" rows="3" id="serviceContent"></textarea>
						        </div>
						    </div>
						</div>
		            </div>
		        </div>
			</div>
			<div class="weui-btn-area" style="margin-bottom: 20px;">
			    <a class="weui-btn weui-btn_primary" href="javascript:" id="reqServiceBtn">申请服务</a>
			</div>
	</div>
	<script type="text/javascript">
	    $(function () {
	    	var sx_area2 = '${param.sx_area2}';
	    	var avgvalue = '${param.avgvalue}';
	    	var serviceId = '${param.id}';
	    	var userId = '-1';
	    	var orgId = '-1';
	    	wxUtils.loadData({
	    		urlFun:function(){
	    			return JSON.stringify({"id":"${param.id}","method":"service_info"});
	    		},
	    		showFun:function(data){
	    			 var bean = data.datalist[0];
	    			 var xj = '';
	    			 if(avgvalue!='null'){
	    				 xj = '('+avgvalue+'星)';
	    			 }
	                 $("#service_name").append(bean["SERVICE_NAME"]+xj);
	                 $("#service_type").append(wxUtils.defaultIfEmpty(bean["SERVICE_NEW_TYPE1"]));
	                 $("#service_commt").html(avgvalue+'星');
	                 $("#service_area").append(wxUtils.defaultIfEmpty(sx_area2));
	                 $("#req_count").append(bean["APPLIED_NUM"]+'次');
	                 $("#service_way").append(wxUtils.getServiceWay(bean["MAIN_SERVICE_MODE"]));
	                 $("#person").append(wxUtils.defaultIfEmpty(bean["RESPONSIBLEMEN_NAME"]));
	                 $("#area").append(wxUtils.defaultIfEmpty(bean["SERVICE_AREA"]));
	                 $("#service_org").append(wxUtils.defaultIfEmpty(bean["ORG_NAME"]));
	                 $("#pubtime").append(bean['AUDIT_TIME'].substring(0,10));
	                 $("#service_desc").append(wxUtils.titleFormat(wxUtils.defaultIfEmpty(bean["SERVICE_PROCESS"])));
	                 $("#service_qua").append(wxUtils.titleFormat(wxUtils.defaultIfEmpty(bean["SERVICE_ABILITY"])));
	                 $("#service_charge").append(wxUtils.titleFormat(wxUtils.defaultIfEmpty(bean["SERVICE_CHARGE"])));
	                 loadServiceType($("#service_type"));
	    		}
	    	});
	    	
	    	//加载服务类型
		    var loadServiceType=function(typeObj){
		    	wxUtils.loadDicData({
		    		dicName:'serviceType',
		    		urlFun:function(){
		    			return JSON.stringify({"method":"bigservice"});
		    		},
		    		showFun:function(data){
		    			var item = wxUtils.getDicItem('serviceType','SERVICE_TYPE_CODE',typeObj.html());
		    			typeObj.html(item['SERVICE_TYPE_NAME']);
		    		}
		    	});
		    }
		    
	    	$("#returnBtn").click(function(){
	    		wxUtils.returnList();
	    	});
	    	
	    	$("#reqServiceBtn").click(function(){
	    		wxUtils.getUserInfo(function(data){
	    			//申请
	    			var serviceContent = $.trim($("#serviceContent").val());
		            if(serviceContent==''){
		                wxUtils.alert("申请服务说明不可为空",function(){
		                	$("#serviceContent").focus();
		                });
		                return false;
		            }
		            wxUtils.confirm("确认是否提交服务申请？",function(){
		            	wxUtils.loadData({
	        	    		urlFun:function(){
	        	    			return JSON.stringify({"serviceId":serviceId,"method":"applyservice","userId":data.userid});
	        	    		},
	        	    		showFun:function(datac){
	        	    			if(datac && datac["state"]=="suceess"){
					            	wxUtils.loadData({
					        	    		urlFun:function(){
					        	    			return JSON.stringify({"method":"saveApplayService42","serviceId":serviceId,"userId":data.userid,"orgId":data.orgId,"ApplyDescribe":serviceContent});
					        	    		},
					        	    		showFun:function(data){console.info(data);
					        	    			if(data["state"]=="suceess"){
					        	    				wxUtils.alert("申请服务操作成功");
					                            }else{
					                            	wxUtils.alert("操作失败，请稍后重试");
					                            }
					        	    		}
					        	     });
	        	    			}else{
	        	    				wxUtils.alert("无权限进行申请服务操作");
	        	    			}
	        	    		}
		            	});
		            });
	    		});
	    	});
	    	wxUtils.iniScrollBar();
	    });
	    
	</script>
</body>
</html>

